package com.example.kotlinview

import kotlinx.coroutines.*
import kotlin.concurrent.thread

class CoroutinesTest {

}

fun main() {
//    GlobalScope.launch {
//        println("code in coroutine
//        scope")
//    }
//    Thread.sleep(1000)

//    runBlocking {
//        launch {
//            println("launch1")
//            delay(1000)
//            println("launch1 finished")
//        }
//        launch {
//            println("launch2")
//            delay(1000)
//            println("launch2 finished")
//        }
//    }


    runBlocking {
        val start=System.currentTimeMillis();

       val result1= async {
            println("launch1")
            delay(1000)
            5+5
        }
        val result2= async {
            println("launch2")
            delay(1000)
            5+5
        }
        println(result1.await()+result2.await())
        val  end=System.currentTimeMillis();
        println("耗时${end-start}")
    }
}